<html>
<head>
<title>duetopia - Documentation - OpenSearch</title>
</head>
<body>

<h1>duetopia</h1>

<h2>Installation</h2>

<ul>
<li><a href="#postgis">Setting up PostGIS</a></li>
<li><a href="#geodjango">Installing GeoDjango</a></li>
<li><a href="#configuration">Configuring Database + Server</a></li>
<li><a href="#lighttpd">Lighttpd webserver setup</a></li>
<li><a href="#apache">Apache/mod_python webserver setup </a></li>
</ul>

<h3>Dependencies</h3>

<pre>
/// ubuntu / debian / Sun VirtualBox ubuntu instance:

	apt-get install redland-utils
	apt-get install python-libxml2
	apt-get install python-psycopg2
    apt-get install python-simplejson
	apt-get install postgresql-client-common
	apt-get install postgresql-client-8.3
    
/// install darwin ports for running postgis on Mac OSX 
/// database server can run on root host or (better) on 
/// another host altogether

	sudo port selfupdate
	sudo port install postgis
	sudo port install postgresql83-server
</pre>

<a name="postgis"/>
<h3>Postgres / PostGIS configuration</h3>

<p>From scratch on Mac OSX:</p>

<pre>

/// we need users and groups

	dscl /Local/Default -create /Users/postgres
	dscl /Local/Default -create /Users/postgres UserShell /bin/bash
	dscl /Local/Default -create /Users/postgres RealName PostgreSQL Admin
	dscl /Local/Default -create /Users/postgres UniqueID 100
	dscl /Local/Default -create /Users/postgres PrimaryGroupID 100
	dscl /Local/Default -create /Users/postgres NFSHomeDirectory /opt/local/var/postgres
	dscl /Local/Default -create /Groups/postgres
	dscl /Local/Default -create /Groups/postgres UniqueID 100

	mkdir -p /opt/local/var/postgres/data
	cat > /opt/local/var/postgres/.bashrc <<EOF
. /etc/bashrc
export PATH=/opt/local/bin:/opt/local/sbin:$PATH
EOF


	chown -R postgres:postgres /opt/local/var/postgres
	chmod 700 /opt/local/var/postgres

	# edit /opt/local/etc/LaunchDaemons/org.macports.postgresql83-server/postgresql83-server.wrapper
	# for paths and...
	launchctl load -w /Library/LaunchDaemons/org.macports.postgresql83-server.plist

	su - postgres -c "/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/postgres/data"
	/opt/local/etc/LaunchDaemons/org.macports.postgresql83-server/postgresql83-server.wrapper start

</pre>
<p>An install from debian/ubuntu apt should have done the initial postgres setup and inititation and allow you to begin at:</p>
<pre>
        $ sudo su - postgres
        
	## now as postgres user:
	$ psql83
	CREATE USER envisat;
	CREATE DATABASE envisat;
	\c envisat
	CREATE LANGUAGE 'plpgsql';
	\i /opt/local/var/macports/software/postgis/1.3.3_1/opt/local/share/postgis/lwpostgis.sql
	\i /opt/local/var/macports/software/postgis/1.3.3_1/opt/local/share/postgis/spatial_ref_sys.sql
	GRANT ALL ON DATABASE envisat TO envisat;
	GRANT ALL ON spatial_ref_sys TO envisat;
	GRANT ALL ON geometry_columns TO envisat;

    ## insert redland tables into store
    \i duetopia.sql 
    
    ## 

</pre>

<a name="geodjango"/>
<h3>GeoDjango</h3>

<p>GeoDjango was merged to Django's trunk on 5th August 2008. So use the main Django svn checkout.</p>

<ul>
<li><a href="http://geodjango.org/">http://geodjango.org/</a></li>
<li><a href="http://www.djangoproject.com/documentation/install/#installing-the-development-version">http://www.djangoproject.com/documentation/install/#installing-the-development-version</a></li>
<li>
<pre>
    $ svn co http://code.djangoproject.com/svn/django/trunk/ django-trunk
    $ cd django-trunk
    $ sudo python setup.py install
</pre>

<a name="configuration"/>
<h3>Duetopia configuration</h3>
<p>Configuration files are found in the 'config' section of duetopia. The sample configuration is called simply 'app'; you are free to rename it as long as you supply the appropriate DJANGO_SETTINGS_MODULE in your environment. </p>

<p>config/app/settings.py - edit this to supply your database connection info, at a minimum. Also optional override for webserver path, location of static files, etc.</p>

<pre>
    $ export DJANGO_SETTINGS_MODULE=app.settings
    ## edit settings to add database password information, etc

    ## syncdb loads the django models into the database
    $ python manage.py syncdb
    
    ## runserver allows you to test your configuration on localhost.
    ## Very useful for development, as changes to python modules 
    ## are reloaded while the server is still running
    $ python manage.py runserver 

</pre>

<a name="lighttpd"/>
<h3>Lighttpd configuration</h3>

<p>The lightweight http server lighttpd is a good way to get running if you don't need to maintain an existing instance of apache.

<pre>
# insert lighttpd install info from the trunk version here
</pre>

<a name="apache"/>
<h3>Apache/mod_python configuration</h3>

<a href="http://www.djangoproject.com/documentation/modpython/">Django project - How to Use Django with mod_python</a>

<pre>
# insert sample config here, need to try this out.
</pre>

</body>
</html>

